const {request} = require("express");

const express = require('express');
const app = express();
const mycors=require("./middleware/MyCors")
const cfg=require("./config/config");
const jwtMiddleWare = require("./middleware/jwtMiddleWare");

const commentController = require("./controller/CommentController");
const examineGroupsController = require("./controller/ExamineGroupsController");
const groupsController = require("./controller/GroupsController");
const groupsPeopleController = require("./controller/GroupsPeopleController");
const noticeController = require("./controller/NoticeController");
const readedController = require("./controller/ReadedController");
const userController = require("./controller/UserController");

const errMiddleWare = require("./middleware/ErrMiddleWare");

//post 请求必须加下面两句
app.use(express.json());
app.use(express.urlencoded());
app.use(mycors);
app.use(jwtMiddleWare);

app.use("/api/v1/comments",commentController);
app.use("/api/v1/examineGroups",examineGroupsController);
app.use("/api/v1/groups",groupsController);
app.use("/api/v1/groupsPeople",groupsPeopleController);
app.use("/api/v1/notices",noticeController);
app.use("/api/v1/readed",readedController);
app.use("/api/v1/users",userController);

app.use(errMiddleWare)

app.listen(3000,()=>{
    console.log('server is running on port 3000');
})
